ScxV6Object.ConvertTemplate Method
Converts a template instance from one template to another.
Parameters
- NewTemplate ID
The object identifier of the template that the instance is to be converted to. - Force
A flag indicating whether to force the conversion or not. The default setting is False and the database object is only converted if there are no objects that have been added locally. If set to True, the conversion will occur and locally added objects are deleted.
Remarks
This method will convert all of the objects within an instance to the class of any matching objects in the new template. Any objects which do not exist in the new template will be deleted. Any objects which didn't exist in the old template will be created.
The following example written in VB.NET converts the instance from one template to another.
Dim Svr As ScxV6DbClient.ScxV6Server
Svr = New ScxV6DbClient.ScxV6Server
Svr.Connect("MAIN", "D", "")
Dim Obj As ScxV6DbClient.ScxV6Object
Obj = Svr.FindObject("Group.Instance")
Dim NewTemplate As ScxV6DbClient.ScxV6Object
NewTemplate = Svr.FindObject("Group.Point Template 2")
Try
Obj.ConvertTemplate(NewTemplate.ID, False)
Catch ex As System.Runtime.InteropServices.COMException
If (MsgBox(ex.Message + " Attempt to convert anyway?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok) Then
Obj.ConvertTemplate(NewTemplate.ID, True)
End If
End Try
' Disconnect
Svr.Disconnect()